import Vue from "vue";
import VueRouter from "vue-router";

// ????? 报错
// const login = () => import('@/views/login');
// const layout = () => import('@/views/layout');
// 不报错
import login from '@/views/login';
import layout from '@/views/layout';
import home from '@/views/home';
import qa from '@/views/qa';
import video from '@/views/video';
import my from '@/views/my';

Vue.use(VueRouter);

// 配置路由表
const routes = [
  // 配置登录页
  { path: '/login', name: 'login', component: login },
  // 配置页面组件布局路由
  {
    path: '',   // 注意这里
    // name: 'layout',
    component: layout,
    children: [
      { path: '/home', name: 'home', component: home },
      { path: '/qa', name: 'qa', component: qa },
      { path: '/video', name: 'video', component: video },
      { path: '/my', name: 'my', component: my },
    ]
  }
];

const router = new VueRouter({
  routes,
});


export default router;